<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\admin\model;

class AppConfig extends \app\BaseModel
{
    protected $name = "longbing_card_config";
    protected static function init()
    {
    }
    public function initConfig($uniacid)
    {
        return self::create(["uniacid" => $uniacid]);
    }
    public function getConfig($uniacid)
    {
        $key = "longbing_card_config_";
        $cacheData = getCache($key, $uniacid);
        $cacheData = false;
        if($cacheData) {
            $cacheData["fromCache"] = 1;
            return $cacheData;
        }
        $data = self::where([["uniacid", "=", $uniacid]])->find();
        if(!$data) {
            $data = $this->initConfig($uniacid);
        }
        $data = $data->toArray();
        $data = transImagesOne($data, ["vr_cover", "default_video", "default_voice", "appoint_pic", "click_copy_show_img", "shop_carousel_more", "copyright", "default_video_cover"], $uniacid);
        setCache($key, $data, 36000, $uniacid);
        return $data;
    }
    public function getConfigByUniacid($uniacid)
    {
        $result = $this->where(["uniacid" => $uniacid])->find();
        if(!empty($result)) {
            $result = $result->toArray();
        }
        return $result;
    }
    public function createConfig($data)
    {
        $data["create_time"] = time();
        $result = $this->save($data);
        return !empty($result);
    }
    public function updateConfig($filter, $data)
    {
        $data["update_time"] = time();
        $result = $this->where($filter)->update($data);
        return !empty($result);
    }
}

?>